package EurekaClientGo

import "time"

type InstanceStatus string

const (
	UP             InstanceStatus = "UP"
	DOWN           InstanceStatus = "DOWN"
	STARTING       InstanceStatus = "STARTING"
	OUT_OF_SERVICE InstanceStatus = "OUT_OF_SERVICE"
	UNKNOWN        InstanceStatus = "UNKNOWN"
)

type DataCenterInfo string

const (
	Netflix DataCenterInfo = "Netflix"
	Amazon  DataCenterInfo = "Amazon"
	MyOwn   DataCenterInfo = "MyOwn"
)

type ActionType string

const (
	ADDED    ActionType = "ADDED"
	MODIFIED ActionType = "MODIFIED"
	DELETED  ActionType = "DELETED"
)

const VERSION_UNKNOWN = "unknown"
const DEFAULT_PORT = 7001
const DEFAULT_SECURE_PORT = 7002
const DEFAULT_COUNTRY_ID = 1

type InstanceInfo struct {
	InstanceId                    string            `xml:"instanceId"`
	AppName                       string            `xml:"appName"`
	AppGroupName                  string            `xml:"appGroupName"`
	IpAddr                        string            `xml:"ipAddr"`
	Port                          int               `xml:"port"`
	SecurePort                    int               `xml:"securePort"`
	HomePageUrl                   string            `xml:"homePageUrl"`
	StatusPageUrl                 string            `xml:"statusPageUrl"`
	HealthCheckUrl                string            `xml:"healthCheckUrl"`
	SecureHealthCheckUrl          string            `xml:"secureHealthCheckUrl"`
	VipAddress                    string            `xml:"vipAddress"`
	SecureVipAddress              string            `xml:"secureVipAddress"`
	StatusPageRelativeUrl         string            `xml:"-"`
	StatusPageExplicitUrl         string            `xml:"-"`
	healthCheckRelativeUrl        string            `xml:"-"`
	healthCheckSecureExplicitUrl  string            `xml:"-"`
	vipAddressUnresolved          string            `xml:"-"`
	secureVipAddressUnresolved    string            `xml:"-"`
	healthCheckExplicitUrl        string            `xml:"-"`
	IsSecurePortEnabled           bool              `xml:"isSecurePortEnabled"`
	IsUnsecurePortEnabled         bool              `xml:"isUnsecurePortEnabled"`
	DataCenterInfo                DataCenterInfo    `xml:"dataCenterInfo"`
	HostName                      string            `xml:"hostName"`
	Status                        InstanceStatus    `xml:"status"`
	OverriddenStatus              InstanceStatus    `xml:"overriddenStatus"`
	IsInstanceInfoDirty           bool              `xml:"-"`
	LeaseInfo                     LeaseInfo         `xml:"leaseInfo"`
	IsCoordinatingDiscoveryServer bool              `xml:"isCoordinatingDiscoveryServer"`
	Metadata                      map[string]string `xml:"metadata"`
	LastUpdatedTimestamp          int64             `xml:"lastUpdatedTimestamp"`
	LastDirtyTimestamp            int64             `xml:"lastDirtyTimestamp"`
	ActionType                    ActionType        `xml:"actionType"`
	AsgName                       string            `xml:"asgName"`
	Version                       string            `xml:"version"`
}

func (i *InstanceInfo) InitDefaults() {
	i.LastUpdatedTimestamp = time.Now().UnixNano() / int64(time.Millisecond)
	i.LastDirtyTimestamp = i.LastUpdatedTimestamp
	i.Status = UP
	i.IsSecurePortEnabled = false
	i.IsUnsecurePortEnabled = true
	i.OverriddenStatus = UNKNOWN
	i.IsInstanceInfoDirty = false
	i.IsCoordinatingDiscoveryServer = false
	i.Version = VERSION_UNKNOWN
}

type PortWrapper struct {
	Enable bool
	Port   int
}

type LeaseInfo struct {
	renewalIntervalInSecs int
	durationInSecs        int
	registrationTimestamp int64
	lastRenewalTimestamp  int64
	evictionTimestamp     int64
	serviceUpTimestamp    int64
}

func loadFromYml(name string) {

}
